import packageAxios from '../request';
const axios = packageAxios.instance;

const apiVersion = '/api/v1/orders/';

const orderInfo = {
    // 获取所有的订单列表
    orderList () {
        return axios.get(apiVersion);
    },
    // 发布订单
    issue (formData) {
        return axios.put(apiVersion + 'order', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    },
    // 获取某份订单信息
    detail (id) {
        return axios.get(apiVersion + 'detail/' + id);
    },
    findUserorders (id) {
        return axios.get(apiVersion + id);
    },
    delete (params) {
        return axios.delete(apiVersion, { params });
    },
    // json格式
    update (data) {
        return axios.post(apiVersion, data);
    },
    // form-data
    updateOrder (data) {
        return axios.post(apiVersion + 'order', data, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    },
    findSpecified (data) {
        return axios.get(apiVersion + 'byCondition', {
            params: data
        });
    }
};

export default orderInfo;
